from datetime import datetime
from pathlib import Path

import pytest
from loguru import logger

import const
from lib.make_data import init_name
from lib.parser import write_file

now = str(datetime.now().strftime("%Y-%m-%d-%H-%M-%S")).split('.')[0]
logger.add(
    const.LOG_DIR / f'{now}.log',
    rotation='200 MB',
    compression='zip',
    backtrace=True,
    diagnose=True,
    enqueue=True
)

PATH = Path(__file__).parent


@pytest.fixture(scope='session', autouse=True)
def init_data():
    path = PATH / 'data' / 'test_flow_data' / "test_merchant_product_flow.yaml"
    print(path)
    data = {"name": init_name()}
    write_file(str(path), data)
